package com.zhongxi.guoyuan.view.seller.offline;

import android.support.annotation.NonNull;

import com.zhongxi.guoyuan.OffLineShop.ConnectNet.NetWork;
import com.zhongxi.guoyuan.OffLineShop.UrlOffLine.RelativeUrl;
import com.zhongxi.guoyuan.application.MyApplication;

import java.io.Reader;
import java.text.SimpleDateFormat;
import java.util.Date;

import io.reactivex.Observable;

/**
 * Created by Administrator on 2018/1/22.
 */

public class AddParameter {
    private AddParameter() {
    }

    private static AddParameter instance;

    public static AddParameter getInstance() {
        if (instance == null) {
            instance = new AddParameter();
        }
        return instance;
    }

    public Observable getInnerMal() {
        return NetWork.getOffLineApi().sellerOffLineInnermallApi(RelativeUrl.INNERMALL + MyApplication.getInstance().getUrl(),
                MyApplication.getInstance().getCheck(true));
    }

    public Observable getMarketOrderByTime() {
        SimpleDateFormat mFormat = new SimpleDateFormat("yyyy-MM-dd");
        String mS = mFormat.format(new Date());
        return NetWork.getOffLineApi().sellerOrderByTimeApi(RelativeUrl.OFFLINEMARKETORDERBYTIME + MyApplication.getInstance().getUrl(),
                MyApplication.getInstance().getCheck(true), mS, mS);
    }

    public Observable getMarketOrderList() {
        return NetWork.getOffLineApi().sellerOrderListApi(RelativeUrl.OFFLINEMARKETORDERLIST + MyApplication.getInstance().getUrl(),
                MyApplication.getInstance().getCheck(true), 1, "");
    }

    ///////////////////////////////////////////////////////////////

    public Observable getAdData(int type) {
        return NetWork.getOffLineApi().getAdApi(RelativeUrl.AdUrl + MyApplication.getInstance().getUrl(),
                MyApplication.getInstance().getCheck(false), type);
    }

    public Observable getNewMessage() {
        return NetWork.getOffLineApi().messageApi(RelativeUrl.NEWMESSAGE + MyApplication.getInstance().getUrl(),
                MyApplication.getInstance().getCheck(false));
    }

    public Observable upDataVersion() {
        return NetWork.getOffLineApi().upDataVersionApi(RelativeUrl.VERSIONUPDATA + MyApplication.getInstance().getUrl(),
                MyApplication.getInstance().getCheck(false));
    }

    public Observable getStoreCate() {
        return NetWork.getOffLineApi()
                .getStoreCateList(RelativeUrl.StoreCateList + MyApplication.getInstance().getUrl(),
                        MyApplication.getInstance().getCheck(false));
    }

    public Observable getStoreList(int page, int orderBy, String cateid) {
        return NetWork.getOffLineApi()
                .getMarketshopOfEntry(RelativeUrl.StoreList + MyApplication.getInstance().getUrl(), MyApplication.getInstance().getCheck(false),
                        page, orderBy, cateid, MyApplication.getInstance().getLongitude(), MyApplication.getInstance().getLatitude());
    }
}
